package demo4;

public class Computer {
    public void openComputer(){
        System.out.println("打开电脑！");
    }
    public void closeComputer(){
        System.out.println("关闭电脑！");
    }
    public void usbFuction(IUSB iusb){
        //打开电脑
        openComputer();
        //使用USB设备
        iusb.open();//打开设备
        if(iusb instanceof Mouse){
           Mouse mouse=(Mouse)iusb;
            mouse.click();//点击鼠标
        }else if(iusb instanceof KeyBoard){
            KeyBoard keyBoard=(KeyBoard)iusb;
            keyBoard.input();
        }
        iusb.close();//关闭设备
        closeComputer();//关闭电脑

    }
}
